<template>
  <div class="addParking">
    <el-form  style="padding: 0 80px;" :rules="rules" ref="ruleForm">
      <el-form-item label="商户编号: " prop="partnerCode">
        <el-input v-model="partnerCode" style="width: 200px;"></el-input>
      </el-form-item>
      <p style="text-align: center;">
        <el-button>取消</el-button>
        <el-button type="primary" @click="submit('ruleForm')">确认</el-button>
      </p>
    </el-form>

    <el-dialog :visible.sync="parkingDataShow" width="400px" :modal-append-to-body="false">
      <el-form :model="parkingData" style="padding: 0 20px;">
        <el-form-item label="停车场名称:">{{parkingData.parkName}}</el-form-item>
        <el-form-item label="停车场地址:">{{parkingData.parkAddress}}</el-form-item>
        <el-form-item label="联系电话:">{{parkingData.telephone}}</el-form-item>
        <el-form-item label="收费规则:">{{parkingData.priceDesc}}</el-form-item>
        <p style="text-align: center;">
          <el-button type="primary" @click="confirm">确认</el-button>
        </p>
      </el-form>
    </el-dialog>

  </div>
</template>

<script>
  export default {
    name: 'addParking',
    data() {
      return {
        partnerCode: null,
        parkingData:{},
        parkingDataShow: false,
        rules: {
          partnerCode: [
            { required: true, message: '请输入商户编号', trigger: 'blur' },
          ],
        }
      }
    },
    mounted() {

    },
    methods: {
      submit(ruleForm) {
        console.log(ruleForm)
         this.$refs[ruleForm].validate((valid) => {
          if (valid) {
            this.$axios({
              method: 'get',
              url: '/park/park-info/getParkingLotByCode',
              params: {partnerCode: this.partnerCode}
            }).then((res) => {
              if(res.data) {
                this.parkingData = res.data;
                this.parkingDataShow = true;
              } else {
                this.$message.warning('未查询到停车场信息')
              }
            })
          } else {
            console.log('error submit!!');
            return false;
          }
        });

      },
      confirm() {
        this.parkingDataShow = false;
        this.$emit('closeDialog',false)
      }
    }
  }
</script>

<style scoped>


</style>
